package com.lzhsite.technology.designPattern.factory.TextImageReadDemo;

import java.io.File;
import java.io.FileInputStream;
/**
 *  类描述：文本读取
 *           
 */
public class TextRead implements IRead<String> {
	
	public String read(String... in) {
		
		String result = null;
		try{
			File file = new File(in[0]);
			long len = file.length();//文件长度
			FileInputStream fis = new FileInputStream(in[0]);//in[0] 存储文件名称
			byte buf[] = new byte[(int)len];
			fis.read(buf);
			result = new String(buf, in[1]);//in[1]存储编码方式
			fis.close();
		}catch(Exception e){
			
			System.out.println(e.getMessage());
		}
		return result;
	}
}
 
